home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 017 / bat203.lbr / batdem.bat < prev    next >
DOS Batch File  |  2011-02-01  |  4KB  |  116 lines

  1. bat * Begin Extended Batch Demo *
  2.  
  3. bat * Standary DOS commands can be intermixed freely with BAT commands.
  4. bat * Like basic, putting things at top is quicker for goto's / loops to find.
  5. bat * Up to 15 chars are allowed for labels, contents of vars, and literals
  6. bat * Ten variables are provided & may be passed to/from DOS. They're %0 to %9.
  7. bat * The variable %R is a return code that any routine can set at 0000:04FE
  8. bat * Note that 'begtype' does not do variable substitution, and all others do.
  9. bat * Spaces are needed to delimit operators.
  10. bat * Non-spaces will concatenate variables and literals.
  11. bat * STATEOF sets return code based on state of files existance. See example.
  12. bat cls
  13. bat type type your first name and press enter.
  14. bat read %8
  15. bat %7 = 94 |   * (don't look!)
  16. bat goto -top
  17.  
  18. bat * number guessing demo *
  19. bat -i.can.count %6 = 5
  20.    bat type i am thinking of a two digit number, can you guess it?
  21.    bat -c.loop read %5
  22.    bat if %5 = %7 skip 6
  23.    bat %6 = %6 - 1
  24.    bat if %6 <> 0 skip 2
  25.        bat type boo hisss! the number was %7 (press enter)
  26.        bat skip 3
  27.    bat type oh so close! you get %6 more tries.
  28.    bat goto -c.loop
  29.    bat type great! i was afraid you weren't going to get it! (press enter)
  30.    bat read
  31.  
  32. bat -top cls
  33. bat type ======== %8's extended batch sampler menu ===========
  34. bat begtype
  35.  
  36. C - I can Count
  37. D - Directory of available programs
  38. F - Testing for files
  39. S - String operations
  40. X - Exit
  41.  
  42. Select an option and press ENTER.
  43. end
  44. bat -entry read %9
  45. bat %7 = %7 + 1
  46. bat * Skiping is quicker than goto's, but only goes forward.
  47. bat if %9 <> d skip 18
  48.     bat type enter file.spec for files you would like to see, or press ENTER for all.
  49.     bat read %1
  50.     bat if .%1 = . %1 = *.*
  51.     bat -dirques type would you like a (s)tandard or (w)ide directory?
  52.     bat read %2
  53.     bat * Notice you can chain togeather if's, like . . .
  54.     bat if %2 <> s if %2 <> w goto -dirques
  55.     bat %3 =
  56.     bat if %2 = w %3 = /w
  57.     bat cls
  58.     dir %1 %3  (notice that two parms are passed to dos here. %%1 and %%3)
  59.     bat * Returning to Extended Batch demo *
  60.     bat begtype
  61.  
  62.     Press ENTER to continue. . .
  63. end
  64.     bat read
  65.     bat goto -top
  66.  
  67. bat if %9 <> x skip 3
  68.     bat type so long %8... hope you find this extended batch facility useful!
  69.     bat type p.s. for quickie help, just enter 'bat' from dos.
  70.     bat exit
  71.  
  72. bat if %9 = c goto -i.can.count
  73.  
  74. bat if %9 <> f skip 18
  75.     bat type enter a file name for me to serch for.
  76.     bat read %9
  77.     bat type scanning for file: %9 . . .
  78.     bat stateof %9 * this will set the return code up (%R)
  79.     bat if %r <> 0 skip 2
  80.     bat    type the file does exist - exactly as typed.
  81.     bat    skip 7
  82.     bat if %r <> 1 skip 2
  83.     bat    type the file does not exist on any drive.
  84.     bat    skip 5
  85.     bat if %r <> 9 skip 2
  86.     bat    type the file name given is invalid.
  87.     bat    skip 2
  88.     bat type the file does exist - but was found on the %r drive.
  89.     bat type to properly find this file, the complete filename would be %9
  90.     bat type (press enter)
  91.     bat read
  92.     bat goto -top
  93.  
  94. bat if %9 <> s skip 18
  95.     bat type enter 0 to 2 strings for me to check out. (Try one like: prog123)
  96.     bat read %1 %2 %3
  97.     bat if %1 = %2 type the strings are equal.
  98.     bat if %1 <> %2 type the strings are not equal.
  99.     bat * notice a '.' will make sure that null entries can be found
  100.     bat if .%3 <> . type you have entered more than 2 strings!
  101.     bat if .%1 = .  type you haven't entered any strings!
  102.     bat if .%1 <> . type you have entered at least 1 string.
  103.     bat %3 = %2%3%1
  104.     bat type a new variable has been created from them containing: %3
  105.     bat * %1 = %1 + 1
  106.     bat * type the increment of the first string is: %1
  107.     bat * %1 = %1 - 1
  108.     bat * %1 = %1 - 1
  109.     bat * type the decrement of the first string is: %1
  110.     bat type (press enter)
  111.     bat read
  112.     bat goto -top
  113. bat type
  114. bat type you did not select a valid option. type c,d,f,s or x and press enter.
  115. bat goto -entry
  116.